var arr = [1, 2, 3, 4];
arr
  .map((id) => {
    return function (next) {
      Promise.resolve(id).then((d) => {
        console.log("data:" + d);
        setTimeout(next, 1000);
      });
    };
  })
  .reverse()
  .reduce(
    (result, fn) => {
      return function () {
        fn(result);
      };
    },
    function () {
      console.log("end");
    }
  )();
